package dev.ideas.funkyj.sequence;

import dev.ideas.funkyj.tuple.Pair;
import dev.ideas.funkyj.tuple.Trio;
import junit.framework.Assert;
import org.junit.Test;

import java.util.Arrays;
import java.util.List;

import static dev.ideas.funkyj.sequence.Sequence.*;

/**
 */
public class Concat {

    @Test
    public void t1() {
        final Sequence<Integer> seq = from(1, 2, 3, 4).where(even).concat(6, 8);
        Assert.assertEquals(seq.asList(), Arrays.asList(2, 4, 6, 8));
        Assert.assertEquals(seq.asList(), Arrays.asList(2, 4, 6, 8));
    }

    @Test
    public void t2() {
        Assert.assertTrue(
                from(range(1, 4)).where(even).
                concat(
                from(range(1, 4)).where(not(even))).

                sort().asList().
                equals(
                Arrays.asList(1, 2, 3, 4)));
    }

    @Test
    public void t3() {
        final List<Pair<Integer,String>> pairs =
                from(range(1, 4), from("a", "b")).
                concat(from(0).zip("z")).
                asList();
        System.out.println("pairs = " + pairs);
    }

    @Test
    public void t4() {
        final List<Trio<Integer, String, Float>> trios =
                from(range(1, 4), from("a", "b"), from(1f, 4f)).
                        concat(from(0).zip("z").zip(0f)).
                        asList();
        System.out.println("trios = " + trios);
    }
}
